/*
 * Copyright:  2018 smarabbit studio.
 *
 *  Licensed under the Confluent Community License; you may not use this file
 *  except in compliance with the License.  You may obtain a copy of the License at
 *
 *  http://www.confluent.io/confluent-community-license
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *  WARRANTIES OF ANY KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations under the License.
 *
 *  @作   者： 黄开晖 (117227773@qq.com)
 *  @日   期: 2019年12月2日
 */
package com.massyframework.beanskin.util.sorting.graph;

/**
 * 顶点
 * @author huangkh
 */

public class Vertex<T> {
    private T data; 
    private int inDegree, outDegree; 
    private VertexStatus status;
    private int dTime, fTime;//时间标签
    private int parent;//父顶点位置
    private int priority;//优先级，用于优先级搜索
    
    /**
     * 创建新实例
     * @param data {@link T},数据
     */
    public Vertex(T data) {
        this.data = data;
        this.inDegree = 0;
        this.outDegree = 0;
        this.status = VertexStatus.UNDISCOVERED;
        this.dTime = -1;
        this.fTime = -1;
        this.parent = -1;
        this.priority = Integer.MAX_VALUE;
    }
    
    /**
     * 顶点数据
     * @return {@link T}
     */
    public T getData() {
        return data;
    }
    
    /**
     * 设置数据
     * @param data {@link T}
     */
    public void setData(T data) {
        this.data = data;
    }

    /**
     * 入度
     * @return {@link int}
     */
    public int getInDegree() {
        return inDegree;
    }
    
    /**
     * 设置入度
     * @param inDegree {@link int}
     */
    public void setInDegree(int inDegree) {
        this.inDegree = inDegree;
    }
    
    /**
     * 出度
     * @return {@link int}
     */
    public int getOutDegree() {
        return outDegree;
    }
    
    /**
     * 设置出度
     * @param outDegree {@link int}
     */
    public void setOutDegree(int outDegree) {
        this.outDegree = outDegree;
    }
    
    /**
     * 顶点状态
     * @return {@link VertexStatus}
     */
    public VertexStatus getStatus() {
        return status;
    }
    
    /**
     * 设置顶点状态
     * @param status {@link VertexStatus}
     */
    public void setStatus(VertexStatus status) {
        this.status = status;
    }
    
    /**
     * 
     * @return
     */
    public int getdTime() {
        return dTime;
    }
    public void setdTime(int dTime) {
        this.dTime = dTime;
    }
    public int getfTime() {
        return fTime;
    }
    public void setfTime(int fTime) {
        this.fTime = fTime;
    }
    
    /**
     * 父顶点
     * @return {@link int}
     */
    public int getParent() {
        return parent;
    }
    
    /**
     * 设置父顶点
     * @param parent {@link int}
     */
    public void setParent(int parent) {
        this.parent = parent;
    }
    
    /**
     * 优先级
     * @return {@link int}
     */
    public int getPriority() {
        return priority;
    }
    
    /**
     * 设置优先级
     * @param priority {@link int}
     */
    public void setPriority(int priority) {
        this.priority = priority;
    }
    
    @Override
    public String toString() {
        return data +"";
    }
}
